<?php
/* @var $this SiteController */

if (Yii::app()->session["user_id"] == null) {
    $this->redirect(array("site/index"));
}
$this->pageTitle = Yii::app()->name;
?>
<div class="panel">
    <?php echo $this->beginContent("/config/toolbar", array("current" => 1)); ?>
    <?php echo $this->endContent(); ?>

    <div class="panel_body">
        <?php echo CHtml::link("+ เพิ่มผู้ใช้งาน", array("Member/EditProfile"), array("class" => "button")); ?>
        <?php
        $this->renderPartial('_search', array(
            'model' => $model,
        ));
        ?>
        <?php
        $this->widget('zii.widgets.grid.CGridView', array(
            'id' => 'employee-grid',
            'dataProvider' => $model->search(),
            'filter' => $model,
            'htmlOptions' => array('width' => '500px'),
            'columns' => array(
                array(
                    'header' => 'รหัสประจำตัว',
                    'type' => 'html',
                    //'value' => 'CHtml::link($data->id_member, array("Config/EmployeeView", "id" => $data->id_member))',
                    'value' => '$data->id_member',
                    'htmlOptions' => array(
                        'width' => '100px',
                        'align' => 'center'
                    )
                ),
                array(
                    'header' => 'ชื่อ',
                    'type' => 'html',
                    'value' => '$data->f_name',
                    'htmlOptions' => array(
                        'width' => '200px',
                        'align' => 'center'
                    )
                ),
                //'f_name',
                array(
                    'header' => 'นามสกุล',
                    'type' => 'html',
                    'value' => '$data->l_name',
                    'htmlOptions' => array(
                        'width' => '200px',
                        'align' => 'center'
                    )
                ),
                //'l_name',
                array(
                    'header' => 'แผนก',
                    'type' => 'html',
                    'value' => '$data->depart->departname',
                    'htmlOptions' => array(
                        'width' => '200px',
                        'align' => 'center'
                    )
                ),
                //'$data->depart->departname',
                array(
                    'header' => 'ระดับ',
                    'type' => 'html',
                    'value' => '$data->status',
                    'htmlOptions' => array(
                        'width' => '200px',
                        'align' => 'center'
                    )
                ),
                //'status',
                array(
                    'header' => '',
                    'class' => 'CLinkColumn',
                    'imageUrl' => 'images/edit.png',
                    'urlExpression' => 'Yii::app()->createUrl("Member/EditProfile", array("id" => $data->id))',
                    'htmlOptions' => array(
                        'width' => '35px',
                        'align' => 'center'
                    )
                ),
                array(
                    'header' => '',
                    'class' => 'CLinkColumn',
                    'imageUrl' => 'images/delete.png',
                    'urlExpression' => 'Yii::app()->createUrl("Config/EmployeeDelete", array("id" => $data->id))',
                    'htmlOptions' => array(
                        'width' => '35px',
                        'align' => 'center',
                        'onclick' => 'return confirm("ยืนยันการลบ")'
                    )
                )
            ),
        ));
        ?>
    </div>
</div>